/**
 * author:Administrator
 * date:2013-5-26
 */
package com.roc.dao.impl;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.roc.dao.DaoException;
import com.roc.dao.IMerchantModuleRight;
import com.roc.pojo.Operators;
import com.roc.pojo.MerchantModuleRight;

/**
 * @author Administrator
 *
 */
@Repository
public class MerchantModuleRightImpl extends BaseDaoImpl implements
		IMerchantModuleRight {

	/* (non-Javadoc)
	 * @see com.roc.dao.IMerchantModuleRight#findByModuleCode()
	 */
	@Override
	public MerchantModuleRight findByModuleCode(String moduleCode,String merchantNo) throws DaoException {
		MerchantModuleRight result = null;
		try {
			String hql="from MerchantModuleRight t where t.moduleCode=? and t.merchantNo=? ";
			Session session = sessionFactory.getCurrentSession();
			Query query=session.createQuery(hql);
			query.setString(0,moduleCode);
			query.setString(1,merchantNo);
			result = (MerchantModuleRight) query.uniqueResult();
		}catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new DaoException("查询代理商权限出错");
		}
		return result;
	}

}
